package by.admonko.universaltesting.datamodel;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;

import by.admonko.universaltesting.datamodel.enums.OutMethod;

@Entity
public class Test {
	/*
	 * id serial NOT NULL, test_name character varying(200) NOT NULL, test_time
	 * time without time zone, only_owner_upd boolean DEFAULT false,
	 * out_method_id integer NOT NULL, user_group_id integer NOT NULL, owner_id
	 * integer NOT NULL, quest_entry integer NOT NULL,
	 */

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Integer id;

	@Column
	private String testName;

	@Column
	private Long testTime;

	@Column
	private Boolean onlyOwnerUpd;

	@Column
	@Enumerated(EnumType.ORDINAL)
	private OutMethod outMethodId;

	// @MapsId
	@JoinTable(name = "test_2_user_group", joinColumns = { @JoinColumn(name = "test_id") }, inverseJoinColumns = { @JoinColumn(name = "user_group_id") })
	@ManyToMany(targetEntity = UserGroup.class, fetch = FetchType.LAZY)
	private Set<UserGroup> userGroup;

	// @MapsId
	@ManyToOne(fetch = FetchType.LAZY, targetEntity = UserTbl.class)
	private UserTbl owner;

	@Column
	private Integer questEntry;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getTestName() {
		return testName;
	}

	public void setTestName(String testName) {
		this.testName = testName;
	}

	public Long getTestTime() {
		return testTime;
	}

	public void setTestTime(Long testTime) {
		this.testTime = testTime;
	}

	public Boolean getOnlyOwnerUpd() {
		return onlyOwnerUpd;
	}

	public void setOnlyOwnerUpd(Boolean onlyOwnerUpd) {
		this.onlyOwnerUpd = onlyOwnerUpd;
	}

	public OutMethod getOutMethod() {
		return outMethodId;
	}

	public void setOutMethod(OutMethod outMethod) {
		this.outMethodId = outMethod;
	}

	public Set<UserGroup> getUserGroup() {
		return userGroup;
	}

	public void setUserGroup(Set<UserGroup> userGroup) {
		this.userGroup = userGroup;
	}

	public UserTbl getOwner() {
		return owner;
	}

	public void setOwner(UserTbl owner) {
		this.owner = owner;
	}

	public Integer getQuestEntry() {
		return questEntry;
	}

	public void setQuestEntry(Integer questEntry) {
		this.questEntry = questEntry;
	}

}
